#! /bin/tcsh 
#------------------------------------------------
# Author:    kasula
# Created:   Thu Jul 21 23:01:48 PDT 2011
# File Name: Comm
# 
# 
# 
# 
#------------------------------------------------
if ($#argv != 3) then
        echo "$0:t : Improper args list..."
        echo "Usage: file1  <minus|and|or> file2"
        exit 8
endif

set tmpFile1 = .comm.`head /dev/urandom | uuencode -m - | sed -n 2p | sed 's#[^a-zA-Z0-9_]##g' | cut -b 1-32`
set tmpFile3 = .comm.`head /dev/urandom | uuencode -m - | sed -n 2p | sed 's#[^a-zA-Z0-9_]##g' | cut -b 1-32`

sort $argv[1] -o $tmpFile1
sort $argv[3] -o $tmpFile3

switch ($argv[2])
case "minus":
        comm -23 $tmpFile1 $tmpFile3
        breaksw
case "and":
        comm -12 $tmpFile1 $tmpFile3
        breaksw
case "or":
        sort -u $tmpFile1 $tmpFile3
        breaksw
default:
        echo "Usage: file1  <minus|and|or> file2"
        exit 8
        breaksw
endsw
rm -f $tmpFile1 $tmpFile3
